<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class BiayaSiswa extends MY_FPDF {

    function Header() {
       
//Logo
        $this->Image($this->logourl, 3, 3, 15);

//Arial bold 15
        $this->SetFont('Arial', 'B', 12);
        $this->SetTextColor(1, 50, 155);
        $this->SetY(8);
        $this->Cell(13);
        $this->Cell(70, 5, $this->namasekolah, 0);
        $this->Cell(117, 5, '',0);
        $this->Ln(5);
        $this->SetFont('Arial', 'B', 8);
        $this->Cell(13);
        $this->Cell(70, 3, $this->alamat,0);        
        
        
        $this->SetFont('Arial', 'I', 8);
        $this->SetY(8);
        $this->Cell(157);
        $this->Cell(20, 3, 'Tanggal Cetak', 0, 0, 'L');
        $this->Cell(3, 3, ':', 0, 0, 'C');
        $this->Cell(20, 3, date('d/m/Y'), 0, 0, 'R');
        $this->Ln(3);
        $this->Cell(157);
        $this->Cell(20, 3, 'Waktu Cetak', 0, 0, 'L');
        $this->Cell(3, 3, ':', 0, 0, 'C');
        $this->Cell(20, 3, date('h:i:s'), 0, 0, 'R');
        $this->Ln(3);
        $this->Cell(157);
        $this->Cell(20, 3, 'Halaman', 0, 0, 'L');
        $this->Cell(3, 3, ':', 0, 0, 'C');
        $this->Cell(20,3, $this->PageNo() . ' dari {nb}', 0, 0, 'R');
//        $this->Ln();
        $this->SetDrawColor(1, 50, 155);
        $this->SetLineWidth(.25);
        $this->Line(5, 19, 205, 19);
        
        $this->Ln(6);
        
        $this->SetTextColor(0, 0, 0);
        $this->SetX(5);
        $this->SetFont('Arial', 'B', 10);
        $this->Cell(0, 5, 'DAFTAR BIAYA SISWA', 0, 0, 'C');
        $this->Ln();
        $this->SetX(5);
        $this->SetFont('Arial', '', 10);
        if(count($this->dataheader)>0){
            $this->Cell(0, 5, 'TAHUN AJARAN '.$this->dataheader->retval, 0, 0, 'C');        
        }else{
            $this->Cell(0, 5, '', 0, 0, 'C');        
        }
        
        $this->Ln(10);
    }
    public function set_header_column($w) {
//        nis,nama,kd_kelas,kelas,kd_biaya,biaya,biaya_dasar,biaya_dikenakan
        $head = array('','No', 'Kode Biaya', 'Biaya', 'Biaya Dasar', 'Biaya Dikenakan');
        $alignhead=array('C', 'C', 'C', 'C', 'C', 'C');
        $borderhead=array(0, 'TBL', 'TBL', 'TBL', 'TBL',1);
        $this->SetFont('Arial', 'B', 8);
        $this->SetX(5);
        for($i=0;$i<count($w);$i++){
            $this->Cell($w[$i], 4, $head[$i], $borderhead[$i], 0,$alignhead[$i]);
        }
        $this->Ln();
    } 
    public function create_pdf($data){
        $this->AddPage();
        $this->SetAutoPageBreak(true,18);
        $w=array(10, 10, 20, 50, 30, 30);
        $al=array('C','R','C', 'L', 'R','R');
        $this->SetWidths($w);
        $this->SetAligns($al);
        $this->lineh=4;
        
        $kelas='';
        $nis='';
        $number=0;
        foreach ($data as $v) {
            if($v->kd_kelas !== $kelas)
            {
//                $this->Ln();
                $number=0;
                $kelas=$v->kd_kelas;
                $this->CheckPageBreak($this->lineh+8);
                $this->SetFont('Arial', 'B', 8);
                $this->SetX(5);
                $this->Cell(200, $this->lineh, $v->kelas, 0, 0, 'L', false);
                $this->SetLineWidth(.25);
                $this->Line(5, $this->GetY()+$this->lineh, 40, $this->GetY()+$this->lineh);
                $this->Ln();
            }
            if($v->nis !== $nis)
            {
//                $this->Ln();
                $number=0;
                $nis=$v->nis;
                $this->CheckPageBreak($this->lineh+8);
                $this->SetFont('Arial', 'BI', 8);
                $this->SetX(15);
                $this->Cell(190, $this->lineh, $v->nis.' - '.$v->nama, 0, 0, 'L', false);
                $this->Ln();
                $this->set_header_column($w);
            }
            $number++;
            $this->SetFont('Arial', '', 8);
//            nis,nama,kd_kelas,kelas,kd_biaya,biaya,biaya_dasar,biaya_dikenakan
            $this->RowHead(
                        array(
                            '',
                            $number,                            
                            $v->kd_biaya,
                            $v->biaya,
                            $v->biaya_dasar,
                            $v->biaya_dikenakan
                            
                        ),
                        $w,
                        $al,   
                        $this->lineh,0,1,1,array(1,2,3,4,5),true
//                     3,0,1,'T',array(5,6,7)
                    );
        }
    }
 }
?>
